package unit10;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;

public class Ex10_7_JTableDemo {
    private static JTable table;

    public static void main(String[] args) {
        JFrame jFrame = new JFrame();
        String[] columnNames = { "学号", "姓名", "年龄" };
        Object[][] rowData = { { "J10001", "张三", 18},
            { "J10002", "李四", 18},
            { "J10003", "王五", 18}
        };
        //创建JTable对象
        JTable studentTable = new JTable(rowData, columnNames);
        //以studentTable做参数构建jScrollPane
        JScrollPane jScrollPane = new JScrollPane(studentTable);
        jFrame.add(jScrollPane);
        jFrame.setSize(600, 400);
        jFrame.setVisible(true);
    }
}
